<script type="text/javascript">
<!--
$(document).ready(function(){
    $('.del_product').click(function(){
        i = $(this);
        if (!confirm('Bạn có chắc chắn muốn xóa sản phẩm này không ?')){
            return false;
        }
        $.post(ADMIN_URL+'/product/delete', {id: i.attr('_id')}, function(data){
            if (data == true){
                i.parent().parent().remove();
            }
        });
    });

    $('.hover').popover({
    	html: true
    })
});
//-->
</script>
<div class="content_wrapper">
    <legend>Danh sách sản phẩm</legend>
    <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered table-condensed" id="example" width="100%">
        <thead>
            <tr>
                <th width="25" style="text-align: center;">ID</th>
                <th>Tên sản phẩm</th>
                <th width="150" style="text-align: center;">Danh mục</th>
                <th width="150" style="text-align: center;">T/Hiệu</th>
                <th width="60" style="text-align: center;">Giá cũ</th>
                <th width="60" style="text-align: center;">Giảm</th>
                <th width="60" style="text-align: center;">Giá mới</th>
                <th width="20" style="text-align: center;">SL</th>
                <th width="30" style="text-align: center;">Xem</th>
                <th width="70" style="text-align: center;">Tùy chọn</th>
            </tr>
        </thead>
        <tbody>
            <?php if (count($result) > 0):?>
            <?php foreach($result as $key => $value) :?>
             <tr>
                <td style="text-align: center;"><?php echo $value['product_id'];?></td>
                <td><a class="hover" data-content="<img src='<?php echo base_url('images/w300/uploads/product/'.$value['product_id'].'/'.md5($value['product_id']).'.jpg');?>' />" href="<?php echo base_url('admin/product/update/'.$value['product_id']); ?>"><?php echo $value['title'];?></a></td>
                <td style="text-align: center;"><a href="<?php echo base_url('admin/category/update/'.$value['category_id']); ?>"><?php echo @$category[$value['category_id']];?></a></td>
                <td style="text-align: center;"><a href="<?php echo base_url('admin/manufacturer/update/'.$value['manufacture']); ?>"><?php echo @$manufacturer[$value['manufacture']];?></a></td>
                <td style="text-align: right;"><?php echo currency_format($value['price_old']);?></td>
                <td style="text-align: right;"><?php echo $value['discount'] ? $value['discount'].' %' : '';?></td>
                <td style="text-align: right;"><?php echo currency_format($value['price_new']);?></td>
                <td style="text-align: center;"><?php echo $value['quantity'];?></td>
                <td style="text-align: center;"><?php echo $value['viewed'];?></td>
                <td style="text-align: center;">
                    <i title="Sản phẩm hot" _id_key="product_id" _id_value="<?php echo $value['product_id'];?>" _field_key="hot_flag" _field_value="<?php echo $value['hot_flag'];?>" _table="<?php echo TBL_PRODUCT;?>" _icon_active="icon-star" _icon_unactive="icon-star-empty" class="btn_active <?php echo ($value['hot_flag'] == 1) ? 'icon-star' : 'icon-star-empty'; ?>"></i>
                    <i title="Kích hoạt" _id_key="product_id" _id_value="<?php echo $value['product_id'];?>" _field_key="active_flag" _field_value="<?php echo $value['active_flag'];?>" _table="<?php echo TBL_PRODUCT;?>" _icon_active="icon-ok" _icon_unactive="icon-ban-circle" class="btn_active <?php echo ($value['active_flag'] == 1) ? 'icon-ok' : 'icon-ban-circle'; ?>"></i>
                    <a href="<?php echo base_url('admin/product/update/'.$value['product_id']);?>"><i class="icon-edit"></i></a>
                    <a href="javascript: void(0);" _id="<?php echo $value['product_id'];?>" class="del_product"><i class="icon-remove"></i></a>
                </td>
            </tr>
            <?php endforeach;?>
            <?php else:?>
            <tr><td colspan="10">Chưa có dữ liệu sản phẩm</td></tr>
            <?php endif;?>
        </tbody>
    </table>
</div>
